package top.csy8888.ch12.document;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Mapping;

/**
 * @author CSY
 * @date 2025 - 10 - 21
 * 文档映射，映射Users索引中的属性（与es索引对应）
 * 使用@Document注解映射
 *
 * indexName指定索引名称
 * createIndex索引不存在是否自动创建
 */
@Document(indexName = "users",createIndex = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Users {
    @Id
    private String id;
    @Field(type = FieldType.Keyword,index = false)
    private String name;
    @Field(type = FieldType.Integer,index = false)
    private Integer age;
    //使用ik分词器分词
    @Field(type = FieldType.Text,analyzer = "ik_max_word")
    private String birthplace;
}
